<!DOCTYPE html>
<html lang="zh-cn">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>什么都论坛-后台评论管理</title>
  <style>
     body {
      background: #f7f9fb;
      margin: 0;
      padding: 0;
    }

    .container {
      width: 90%;
      max-width: 1100px;
      margin: -50px auto;
      background: #fff;
      border-radius: 10px;
      box-shadow: 0 2px 12px rgba(80, 133, 203, 0.08);
      padding: 30px;
    }

    .container h2 {
      margin-top: 0;
      color: #0327b3;
      text-align: center;
      padding: 0;
      margin: 0 auto 10px;
    }

    .actions {
      margin-bottom: 20px;
      text-align: right;
    }

    .actions button {
      background: #2a4dd0;
      color: #fff;
      border: none;
      border-radius: 5px;
      padding: 8px 18px;
      font-size: 15px;
      cursor: pointer;
      transition: background 0.2s;
      margin-left: 10px;
    }

    .actions button:hover {
      background: #0327b3;
    }

    table {
      width: 100%;
      border-collapse: collapse;
      margin-bottom: 30px;
      background: #f9fbfd;
      border-radius: 8px;
      overflow: hidden;
      box-shadow: 0 1px 4px rgba(80, 133, 203, 0.04);
    }

    th,
    td {
      padding: 12px 10px;
      text-align: left;
    }

    th {
      background: #5085cb;
      color: #fff;
      font-weight: 600;
      border-bottom: 2px solid #e3eaf6;
    }


    tr:hover {
      background: #eaf2ff;
      transition: background 0.2s;
    }

    td {
      color: #333;
      font-size: 15px;
      border-bottom: 1px solid #e3eaf6;
    }

    .avatar {
      width: 50px;
      height: 50px;
      border-radius: 50%;
      /* object-fit: cover; */
      border: 1.5px solid #e3eaf6;
      background: #fff;
      box-shadow: 0 1px 3px rgba(80, 133, 203, 0.08);
    }

    .delete {
      background: #e74c3c;
      color: #fff;
      border: none;
      border-radius: 5px;
      padding: 6px 16px;
      font-size: 14px;
      cursor: pointer;
      transition: background 0.2s;
    }

    .delete:hover {
      background: #c0392b;
    }

    .ellipsis {
      max-width: 200px;
      height: 79px;
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
    }

    .ellipsis:hover {
      color: #2a4dd0;
      cursor: pointer;
      overflow: auto;
      white-space: normal;
      text-overflow: clip;
    }
  </style>
</head>

<body>
  <div class="container">
    <h2>评论管理</h2>
    <div class="actions">
      <button onclick="location.reload()">刷新</button>
    </div>
    <table>
      <thead>
        <tr>
          <th>评论帖子</th>
          <th>ID</th>
          <th>头像</th>
          <th>用户名</th>
          <th>评论内容</th>
          <th>评论时间</th>
          <th>操作</th>
        </tr>
      </thead>
      <tbody>
        <?php
        require_once "../model/replyBmsDao.php";
        $reply_info = get_all_reply_info();
        // var_dump($reply_info);
        foreach ($reply_info as $reply) {
          echo "<tr>";
          echo "<td class='ellipsis'>" . $reply['title'] . "</td>";
          echo "<td>" . $reply['uId'] . "</td>";
          echo "<td><img src='../../bbs/image/head/{$reply['head']}' alt='头像' style='width: 50px; height: 50px; border-radius: 50%;'></td>";
          echo "<td>" . $reply['uName'] . "</td>";
          echo "<td class='ellipsis' >" . $reply['content'] . "</td>";
          echo "<td class='ellipsis'>" . $reply['publishTime'] . "</td>";
          echo '<td><button onclick="if(confirm(\'确认删除吗？\')) { location.href=\'../control/doPost.php?replyId=' . $reply['replyId'] . '\'; }" class="delete">删除</button></td>';
          echo "</tr>";
        }
        ?>
      </tbody>
    </table>
  </div>

</body>

</html>